$(function () {
    let form = layui.form
    form.verify({
        Pwd: [
            /^[\S]{6,12}$/,
            '请输入6到12位非空字符串'
        ],
        newPwd: function (value) {
            let v1 = $('[name =oldPwd]').val()
            if (value === v1) {
                return '原密码与新密码不能一致'
            }
        },
        rePwd: function (value) {
            let v2 = $('[name = newPwd]').val()
            if (value !== v2) {
                return '两次密码不一致'
            }
        }
    })
    $('#formPwd').on('submit', function (e) {
        e.preventDefault()
        axios({
            url:'/my/updatepwd',
            method:'post',
            data:$(this).serialize(),
        }).then(res=>{
            //成功回调
            console.log(res)
            if (res.data.status != 0) {
                return layui.layer.msg(res.data.message)
            }
            layui.layer.msg('恭喜这个逼')
            $('form')[0].reset()
            setTimeout(() => {
                window.parent.location.href = '/login.html'
            }, 2000);
        });
    })
})